package me.jessyan.armscomponent.app.di.module;

import android.app.Activity;
import android.view.View;

import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.di.scope.ActivityScope;

import java.util.ArrayList;
import java.util.List;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;

import me.jessyan.armscomponent.app.mvp.contract.user.UserTestKnowledgeLevelContract;
import me.jessyan.armscomponent.app.mvp.model.user.UserTestKnowledgeLevelModel;
import me.jessyan.armscomponent.app.mvp.model.entity.Question;
import me.jessyan.armscomponent.app.mvp.ui.adapter.UserTestLevelAdapter;


/**
 * <p>
 * Author: Taozebi
 * Date: 08/19/2021 23:20
 * Description: describe of this class
 */
@Module
public abstract class UserTestKnowledgeLevelModule {

    @Binds
    abstract UserTestKnowledgeLevelContract.Model bindUserTestKnowledgeLevelModel(UserTestKnowledgeLevelModel model);

    @ActivityScope
    @Provides
    static Activity provideActivity(UserTestKnowledgeLevelContract.View view) {
        return view.getActivity();
    }

    @ActivityScope
    @Provides
    static RecyclerView.LayoutManager provideLayoutManager(UserTestKnowledgeLevelContract.View view) {
        return new LinearLayoutManager(view.getActivity());
    }

    @ActivityScope
    @Provides
    static List<Question> provideList() {
        return new ArrayList<>();
    }

    @ActivityScope
    @Provides
    static RecyclerView.Adapter provideMineRewardAdapter(UserTestKnowledgeLevelContract.View mineRewardView,List<Question> list) {
        UserTestLevelAdapter adapter = new UserTestLevelAdapter(mineRewardView.getActivity(),list);
        adapter.setOnItemClickListener(new DefaultAdapter.OnRecyclerViewItemClickListener<Question>() {
            @Override
            public void onItemClick(@NonNull View view, int viewType, @NonNull Question data, int position) {
//                ArmsUtils.snackbarText("position:"+position);
            }
        });
        return adapter;
    }
}